import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { TableService } from './service/table.service';
import { RequirePermission } from '@/common/decorator/require-premission.decorator';
@Controller('system/table')
export class TableController {
    constructor(private tableService: TableService) { }

    
    @RequirePermission("system:account:list")
    @Get('/getTable')
    getTable() {
        return this.tableService.getTable()
    }

    @RequirePermission("system:account:list")
    @Get('/find')
    findTable(@Query('name') name: string) {
        console.log(name);

        return this.tableService.findTable(name)
    }

    @RequirePermission("system:account:list")
    @Post('/updateTable')
    updateTable(@Body('old') old: string, @Body('newone') newone: string) {   
        return this.tableService.updateTable(old,newone)
    }

    @RequirePermission("system:account:list")
    @Post('/addTable')
    addTable(@Body('name') name: string) {
        console.log(name);
        
        return this.tableService.addTable(name)
    }

    @RequirePermission("system:account:list")
    @Post('/delTable')
    delTable(@Body('name') name: string) {
        
        
        return this.tableService.delTable(name)
    }

}
